var Input = {};
Input.keyDown=function(e){ 
};

Input.canvas;

Input.mouseDown = function(e){
	var x;
	var y;
	if (e.pageX || e.pageY) { 
	  x = e.pageX;
	  y = e.pageY;
	}
	else { 
	  x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; 
	  y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; 
	} 
	x -= Input.canvas.offsetLeft;
	y -= Input.canvas.offsetTop;

	if(Game.isRunning)
		Game.movePlayerTo(x,y);
	else
		Game.reset();
}

Input.mouseMove = function(e){
	var x;
	var y;
	if (e.pageX || e.pageY) { 
	  x = e.pageX;
	  y = e.pageY;
	}
	else { 
	  x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; 
	  y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; 
	} 
	x -= Input.canvas.offsetLeft;
	y -= Input.canvas.offsetTop;

	Game.setMousePos(x,y);
}

Input.initialize = function()
{
	Input.canvas = document.getElementById ("view");
	Input.canvas.addEventListener('click',Input.mouseDown,true);
	Input.canvas.addEventListener('mousemove',Input.mouseMove,true);
	window.addEventListener('keydown',Input.keyDown,true);
};

